Skip to content

fix(memcache): normalize Redis TTL handling and return actual compareSetTTL result#62062

Draft
joshtrichards wants to merge 4 commits into
masterfrom
jtr/fix-redis-EXPIRE-TTL
Draft

fix(memcache): normalize Redis TTL handling and return actual compareSetTTL result#62062
joshtrichards wants to merge 4 commits into
masterfrom
jtr/fix-redis-EXPIRE-TTL

Conversation

@joshtrichards

@joshtrichards joshtrichards commented Jul 13, 2026

Copy link
Copy Markdown
Member
  • Resolves: #

Summary

  • Centralize TTL normalization in OC\Memcache\Redis
  • Make compareSetTTL() return the actual result of the underlying Redis EXPIRE call
  • Expand test coverage for TTL handling
  • Update IMemcacheTTL interface docs to match implementation and clarify TTL normalization

Motivation:

TTL handling was duplicated across multiple methods, while compareSetTTL() used slightly different behavior and always reported success when the compare matched, even though the Lua script ignored the actual EXPIRE result. This change makes the behavior more consistent and makes the return value of compareSetTTL() more truthful. Also expands test coverage.

Changes:

  • add a small normalizeTtl() helper and use it for Redis TTL writes
  • align compareSetTTL() TTL handling with the other Redis cache methods
  • update the caSetTtl Lua script to return the result of EXPIRE instead of returning success unconditionally when the compare matches

Notes:

  • Negative TTL values are still passed through intentionally so the existing lock TTL restoration behavior can continue to remove keys immediately when the restored TTL is already elapsed.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

TTL handling was duplicated across multiple methods, while `compareSetTTL()` used slightly different behavior and always reported success when the compare matched, even though the Lua script ignored the actual EXPIRE result.

This change makes the behavior more consistent and makes the return value of `compareSetTTL()` more truthful.

Note: Negative TTL values are still passed through intentionally.

Signed-off-by: Josh <josh.t.richards@gmail.com>
…names

Assisted-by: Copilot:gpt-5.4

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added bug 2. developing Work in progress developer experience feature: caching Related to our caching system: scssCacher, jsCombiner... labels Jul 13, 2026
@joshtrichards joshtrichards added this to the Nextcloud 35 milestone Jul 13, 2026
Signed-off-by: Josh <josh.t.richards@gmail.com>
@susnux susnux added the community pull requests from community label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress AI assisted bug community pull requests from community developer experience feature: caching Related to our caching system: scssCacher, jsCombiner...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants